// StackDumpBox.cpp: implementation of the CStackDumpBox class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "8085.h"
#include "StackDumpBox.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CStackDumpBox::CStackDumpBox()
{
    Init();
}

CStackDumpBox::~CStackDumpBox()
{

}

void CStackDumpBox::Init()
{
    m_nFirstAddress = Get8085Object()->GetSP();
}


int CStackDumpBox::RefreshStrings(int addr, BOOL bCheckModified)
{
    if(m_aDisplay==NULL) return 0;
    addr = Get8085Object()->GetSP();
	int i=0;
    for(i=0; i<m_nItems ; i++)
    {
        word data = ReadMemWord(addr+i*2);
        if(bCheckModified)
        {
            if(m_aDisplay[i].data != data)
                m_aDisplay[i].bModified = 1;
            else m_aDisplay[i].bModified = 0;
        }
        else m_aDisplay[i].bModified = 0;
        if(i==0)
            sprintf(m_aDisplay[i].szMnemonic,"SP   %04x",data);
        else
            sprintf(m_aDisplay[i].szMnemonic,"SP+%01x %04x",i*2,data);
        m_aDisplay[i].address = addr+i;
        m_aDisplay[i].data = data;
    }
    for( ; i<m_nItems; i++)
        sprintf(m_aDisplay[i].szMnemonic," ");

	return m_aDisplay[m_nItems-1].address;
}

